<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>顾客诊断信息管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		#contentTable{margin-left: 0px;}
		 .btn{width:130px;}
		 table tr{
	 		height:40px;
	 	 }
	</style>
	<script type="text/javascript">
		$(document).ready(function() {	
			$("#searchForm").validate({
				submitHandler: function(form){
					var type = $('input:radio[name=searchType]:checked').val();
					var key = $('#keyWord').val();
					if (type == '2'){
							if(!isNaN(key)){
							   loading('正在提交，请稍等...');
							   form.submit();
							}else{
							   showTip("电话号码必须是数字！");
							}
					} else {
						 loading('正在提交，请稍等...');
						 form.submit();
					}
				}
			});	
			$("#contentTable tbody tr").click(function(){
				sessionStorage.parentPageNo = $("#pageNo").val();
				var item = $("#opreation-"+ this.id);
				var status = $(this).attr("status");
				if(item.length > 0) {
					item.remove();
					return;
				}
				$(".opreationTR").removeClass("opreationTR");
				$(".opreation").remove();
				var html= '<tr id="opreation-' + this.id + '" class="opreation"><td colspan="5">';
				if(status == "0"){
					html += '<a data-role="button" data-inline="true"  href="${ctx}/expert/customerSolution/manager?customerExamId=' + this.id + '">方案管理</a>';
				}
				if(status == "0"){
					html += '<button data-inline="true"  onclick="resultDetail(\''+ this.id +'\')">查看已开单方案明细</button>';
				} else if(status == "1"){
					html += '<a data-role="button" data-inline="true" href="${ctx}/expert/customerExam/search?id=' + this.id + '">查看专家推荐方案</a>';
				} else {
					html += '正在诊断中';
				}
				html += "</td></tr>";
				$(this).after(html);
				$(this).addClass("opreationTR");
				$("#contentTable").trigger('create');
			});
			var currentSelectId = '${currentSelectId}';
			if(currentSelectId){
				$("#"+currentSelectId).addClass("opreationTR");
			} else {
				$("#contentTable tbody tr:first-child").addClass("opreationTR");
			}
		});
		
		function resultDetail(id) {
			sessionStorage.parentPageNo = $("#pageNo").val();
			sessionStorage.urlTarget = 'resultList';
			window.location.href ="${ctx}/expert/customerExam/detailResult?id=" + id + "&target=" + sessionStorage.urlTarget;
		}
		
		function returnResult(bool){
			if(bool) {
				$('#mainPanel').css('display','none');
				$('#detailPanel').css('display','block');
			} else {
				$('#mainPanel').css('display','block');
				$('#detailPanel').css('display','none');
			}
		}
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body id="body">
	<form:form id="searchForm" modelAttribute="customerExam" action="${ctx}/expert/customerExam/resultList" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
	        <input type="radio" name="searchType" id="radio-choice-a" value="0" ${empty searchType || searchType == '0' ? 'checked' : ''}>
	        <label for="radio-choice-a">姓名</label>
	        <input type="radio" name="searchType" id="radio-choice-b" value="1" ${searchType == '1' ? 'checked' : ''}>
	        <label for="radio-choice-b">备注名</label>
	        <input type="radio" name="searchType" id="radio-choice-c" value="2" ${searchType == '2' ? 'checked' : ''}>
	        <label for="radio-choice-c">手机号码</label>
		</fieldset> 
		<input id="keyWord" name="keyWord" type="search" data-inline="true" value="${keyWord}"/>
		<input id="btnSubmit" type="submit" value="查询" data-inline="true"/>
	</form:form>
	<tags:message content="${message}"/>
	<div class="icon-buttons">
		<input type="button" class="leave-clean-session" data-inline="true" data-icon="back" data-iconpos="notext" value="返回"/>
	</div>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>顾客姓名</th><th>诊断时间</th><th>美容师</th><th>状态</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="customerExam">
			<tr id="${customerExam.id}" status="${showMap[customerExam.id]}">
				<td>${customerExam.customer.name}</td>
				<td>${fns:formatDate(customerExam.exam_time, "yyyy/MM/dd HH:mm:ss")}</td>
				<td>${customerExam.employee.name}</td>
				<td id="pay-${customerExam.id}">
					<c:if test="${showMap[customerExam.id] == 0}">
						<c:if test="${customerExam.storeConsume != null}">
	    					已付款
						</c:if>
						<c:if test="${customerExam.storeConsume == null}" >
	    					未付款
						</c:if>
					</c:if>
					<c:if test="${showMap[customerExam.id] != 0}">
						<font style="color:red;">未确认</font>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
